import os
from django.core.mail import send_mail
from rest_framework_jwt.settings import api_settings
from mydjango import settings

import random
# 生成token
def create_token(user):
    jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
    jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
    payload = jwt_payload_handler(user)
    token = jwt_encode_handler(payload)
    # data = Login_return(token,)
    return token

# 工单邮件通知
def send_email(jie__shou__fang, name, order_link):
    zhuti = "工单提醒"
    neirong = "工单提醒"
    my_emails = settings.EMAIL_FROM
    print(order_link)
    html_neirong = "尊敬的%s，您有一个新的工单需要处理，请及时查看！%s" % (name, order_link)
    send_mail(zhuti, neirong, my_emails, jie__shou__fang, html_message=html_neirong)